package com.jmpt.fangbohui.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.jmpt.fangbohui.R;
import com.jmpt.fangbohui.bean.HouseMoreCategoryItemValuesBean;
import com.jmpt.fangbohui.bean.HouseMoreSeleteCategoryBean;

public class HouseSeleteMoreRightAdapter extends BaseAdapter {

    public HouseMoreSeleteCategoryBean data;
    private Context mContext;

    public HouseSeleteMoreRightAdapter(Context context, HouseMoreSeleteCategoryBean data) {
        mContext = context;
        this.data = data;

    }


    @Override
    public int getCount() {
        if (data == null || data.values == null) {
            return 0;
        }
        return data.values.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View view, ViewGroup parent) {

        if (view == null) {
            view = View.inflate(mContext, R.layout.item_list_home_selete_right, null);
        }
        HouseMoreCategoryItemValuesBean bean = data.values.get(position);
        
        Holder holder = getHolder(view);
        holder.name.setText(bean.name);

        holder.name.setBackgroundResource(R.drawable.common_hover);
        if (position == data.childSelete) {
            holder.name.setTextColor(mContext.getResources().getColor(R.color.main_tab_font_selete));
        } else {
            holder.name.setTextColor(mContext.getResources().getColor(R.color.font_black));
        }
        return view;
    }

    private Holder getHolder(final View view) {
        Holder holder = (Holder) view.getTag();
        if (holder == null) {
            holder = new Holder(view);
            view.setTag(holder);
        }
        return holder;
    }

    class Holder {
        private TextView name;


        public Holder(View view) {
            name = (TextView) view.findViewById(R.id.name);


        }
    }
}
